56
Beginner’s Guide to Code Algorithms
56
STEP 17
The second step is to scan the putnumberpresent array to identify the other two
corners.
Once identified, all cells in the same two columns that the corners are in get the
candidate number (putnumber) in each of their cantbelist (remember the array that
stores what the cell cannot be?) except for the corners of the rectangle.
:
:
For i = 1 To 9
For j = 1 To 9
If putnumberpresent(j, 1) <> “*” And sbox(j, i) = ““
And putnumberpresent(j, i) <> ““ Then
For k = j To 9
If putnumberpresent(k, i) = putnumberpresent(j, i) And k <> j
And Len(putnumberpresent(j, i)) = 2 And putnumberpresent(1, k) <>
“*” Then
‘row j,k and columns stored in putnumber are the rectangle
‘all cells in the columns of the rectangle except the corners,
‘should have putnumber in cantbelist
For kk = 1 To 9
If kk = j Or kk = k Then
Else
Call addtocantbelist(putnumber, kk, Mid(putnumberpresent(j,
i), 1, 1))
Call addtocantbelist(putnumber, kk, Mid(putnumberpresent(j,
i), 2, 1))
End If
Next kk
End If
Next k
End If
Next j
Next i
:
Next putnumber
There are two final algorithms I wanted to present before moving on to Chapter 4
on remote control.
3.7 THE POLYOMINO
The first one is called the algorithm of the polyomino. A polyomino is a two-dimen
sional figure that you can form by joining multiple squares. It is derived from the term
domino—those little squares used in the domino game.
The second is the algorithm of the matching twin.
Here is how the first one works. In the diagram below, 2 is a candidate in exactly two
cells in columns 2, 3, and 6. Notice how they form a closed pattern. The consequence